package add_$14_Case_8_3;

import java.util.ArrayList;
import java.util.List;

public class Test {

    public static void main(String[] args) {
        
        // 创建两个用户
        User user1 = new User("张三", "22", "222222", "10000");
        User user2 = new User("李四", "333", "333333", "50000");
        
        // 存入userList集合
        List<User> userList = new ArrayList();
        userList.add(user1);
        userList.add(user2);
        
        // 创建Bank对象，将userList传入
        Bank bank = new Bank(userList);
        
        // 创建两个线程
        Thread t1 = new Thread(bank) {
            @Override
            public void run() {
                // TODO Auto-generated method stub
                
                for(int i = 0; i < 10; i++) {
                    
                    bank.saveMoney("22", "222222", "100");
                    bank.delay(10000);
                    bank.drawMoney("22", "222222", "1500");
                    bank.delay(10000);
                    
                    bank.saveMoney("333", "333333", "100");
                    bank.delay(10000);
                    bank.drawMoney("333", "333333", "7000");
                    bank.delay(10000);
                    
                }
            }
        };
        
        Thread t2 = new Thread(bank) {
            
            @Override
            public void run() {
                // TODO Auto-generated method stub
                
                for(int i = 0; i < 10; i++) {
                    
                    bank.saveMoney("333", "333333", "100");
                    bank.delay(10000);
                    bank.drawMoney("333", "333333", "7000");
                    bank.delay(10000);
                    
                    bank.saveMoney("22", "222222", "100");
                    bank.delay(10000);
                    bank.drawMoney("22", "222222", "1500");
                    bank.delay(10000);
                    
                }
            }
        };
        
        
        // 开启线程
        t1.start();
        t2.start();
    }

}
